//
// Created by ecarx on 2022/11/22.
//

#include "com_ecarx_vhaltests_IpcpClient.h"

#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setConfig
 * Signature: (I[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setConfig
        (JNIEnv *env, jobject, jint service_id, jintArray op_ids) {
    uint16_t ser_id = (uint16_t) service_id;
    int *tmp_ops = (*env).GetIntArrayElements(op_ids, JNI_FALSE);
    int len = (*env).GetArrayLength(op_ids);
    LOGE("len: %d", len);
    uint16_t op[len];
    for (int i = 0; i < len; i++) {
        op[i] = (uint16_t) tmp_ops[i];
        LOGE("OP[%d]: %d", i, op[i]);
    }
    bool res = set_config(ser_id, op, len);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setIntPropertyValue
 * Signature: (III)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setIntPropertyValue
        (JNIEnv *env, jobject, jint service_id, jint pro_id, jint pro_value) {
    int serId = (int) service_id;
    int proId = (int) pro_id;
    int proValue = (int) pro_value;
    int *p = &proValue;
    bool res = send_message(serId, proId, (void *) p, sizeof(int));
    return res;
}


/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setStringPropertyValue
 * Signature: (IILjava/lang/String;)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setStringPropertyValue
        (JNIEnv *env, jobject, jint service_id, jint pro_id, jstring pro_value) {
    int serId = (int) service_id;
    int proId = (int) pro_id;
    const char *proValue = (*env).GetStringUTFChars(pro_value, 0);
//    std::string value = proValue;
//    std::cout<<"set value: "+value;
    jsize size = (*env).GetStringUTFLength(pro_value);
    bool result1 = send_message(serId, proId, (void *) proValue, size);
    return result1;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setIntSignal
 * Signature: (IIIIII)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setIntSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jint availability, jint data, jint format,
         jint status) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;
    int sig_avail = (int) availability;
    int sig_data = (int) data;
    int sig_format = (int) format;
    int sig_status = (int) status;
    bool res = set_int_signal(service_id, op_id, sig_avail, sig_data, sig_format, sig_status);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setCarconfigSignal
 * Signature: (II[I[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setCarconfigSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jintArray configArray, jintArray values) {
    int service_id = ser_id;
    int op_id = (int) oper_id;
    //处理config_indexes
    int c_len = (*env).GetArrayLength(configArray);
    int *tmp_configs = (*env).GetIntArrayElements(configArray, JNI_FALSE);
    LOGE("c_len: %d", c_len);
    int config_indexes[c_len];
    for (int j = 0; j < c_len; j++) {
        config_indexes[j] = (int) tmp_configs[j];
        LOGE("config_indexes[%d]: %d", j, config_indexes[j]);
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    uint8_t cValues[v_len];
    for (int i = 0; i < v_len; i++) {
        cValues[i] = (uint8_t) tmp_values[i];
        LOGE("cValues[%d]: %d", i, cValues[i]);
    }
    bool res = set_carconfig_signal(service_id, op_id, config_indexes, cValues, c_len);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setVGMSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setVGMSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray vgms, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;
    //处理vgms
    int vgm_len = env->GetArrayLength(vgms);
    LOGE("vgm_len: %d", vgm_len);
    std::string vgm_indexs[vgm_len];
    for (int j = 0; j < vgm_len; j++) {
        jobject vgm_object = env->GetObjectArrayElement(vgms, j);
        //jobject转化为jstring
        jstring vgm_jstring = static_cast<jstring>(vgm_object);
        //jstring转化为string
        const char *vgm_char = (*env).GetStringUTFChars(vgm_jstring, 0);
        LOGE("vgm_char: %s", vgm_char);
        vgm_indexs[j] = vgm_char;
        LOGE("vgm_indexs[j]: %s", vgm_indexs[j].c_str());
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d", i, vValues[i]);
    }

    //
    bool res = set_vgm_signal(service_id, op_id, vgm_indexs, vValues, vgm_len);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setVDDMSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setVDDMSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray vddms, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;
    int vddm_len = env->GetArrayLength(vddms);
    std::string vddm_indexs[vddm_len];
    for (int j = 0; j < vddm_len; j++) {
        jobject vddm_object = env->GetObjectArrayElement(vddms, j);
        jstring vddm_jstring = static_cast<jstring>(vddm_object);
        const char *vddm_char = (*env).GetStringUTFChars(vddm_jstring, 0);
        vddm_indexs[j] = vddm_char;
    }

    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d", i, vValues[i]);
    }

    bool res = set_vddm_signal(service_id, op_id, vddm_indexs, vValues, vddm_len);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setVGMSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setSRSSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray srs, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;
    //处理srs
    int srs_len = env->GetArrayLength(srs);
    std::string srs_indexs[srs_len];
    for (int j = 0; j < srs_len; j++) {
        jobject srs_object = env->GetObjectArrayElement(srs, j);
        //jobject转化为jstring
        jstring srs_jstring = static_cast<jstring>(srs_object);
        //jstring转化为string
        const char *srs_char = (*env).GetStringUTFChars(srs_jstring, 0);
        LOGE("srs_char: %s", srs_char);
        srs_indexs[j] = srs_char;
        LOGE("srs_indexs[j]: %s", srs_indexs[j].c_str());
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d", i, vValues[i]);
    }

    //
    bool res = set_srs_signal(service_id, op_id, srs_indexs, vValues, srs_len);
    return res;
}
/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setAlive
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_com_ecarx_vhaltests_IpcpClient_setAlive
        (JNIEnv *, jobject, jboolean a) {
    bool aa = (bool) a;
    set_alive(aa);
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    getAlive
 * Signature: ()Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_getAlive
        (JNIEnv *, jobject) {
    bool aa = get_alive();
    return aa;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    getPropertyValueFromMock
 * Signature: (II)Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_com_ecarx_vhaltests_IpcpClient_getPropertyValueFromMock
        (JNIEnv *env, jobject, jint service_id, jint pro_id) {
    int ser_id = (int) service_id;
    int oper_id = (int) pro_id;
    std::string value = get_message(ser_id, oper_id);
    jstring jvalue = env->NewStringUTF(value.c_str());
    return jvalue;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setCarconfig1000Signal
 * Signature: (II[I[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setCarconfig1000Signal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jintArray configArray, jintArray values){
    int service_id = ser_id;
    int op_id = (int)oper_id;
    //处理config_indexes
    int c_len = (*env).GetArrayLength(configArray);
    int* tmp_configs = (*env).GetIntArrayElements(configArray,JNI_FALSE);
    LOGE("c_len: %d",c_len);
    int config_indexes[c_len];
    for(int j=0; j<c_len; j++){
        config_indexes[j] = (int)tmp_configs[j];
        LOGE("config_indexes[%d]: %d",j, config_indexes[j]);
    }

    //处理values
    int* tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d",v_len);
    uint8_t cValues[v_len];
    for(int i=0; i<v_len; i++){
        cValues[i] = (uint8_t)tmp_values[i];
        LOGE("cValues[%d]: %d",i, cValues[i]);
    }
    bool res = set_carconfig1000_signal(service_id,op_id, config_indexes, cValues, c_len);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setTimeoutSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setTimeoutSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray timeouts, jintArray values){
    int service_id = (int)ser_id;
    int op_id = (int)oper_id;
    //处理timeouts
    int vgm_len = env->GetArrayLength(timeouts);
    LOGE("vgm_len: %d", vgm_len);
    std::string vgm_indexs[vgm_len];
    for(int j=0; j<vgm_len; j++){
        jobject vgm_object = env->GetObjectArrayElement(timeouts, j);
        //jobject转化为jstring
        jstring vgm_jstring = static_cast<jstring>(vgm_object);
        //jstring转化为string
        const char *vgm_char = (*env).GetStringUTFChars(vgm_jstring, 0);
        LOGE("vgm_char: %s", vgm_char);
        vgm_indexs[j] = vgm_char;
        LOGE("vgm_indexs[j]: %s", vgm_indexs[j].c_str());
    }

    //处理values
    int* tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d",v_len);
    int vValues[v_len];
    for(int i=0; i<v_len; i++){
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d",i, vValues[i]);
    }

    bool res = set_timeout_signal(service_id, op_id, vgm_indexs, vValues, vgm_len);
    return res;
}
 /*
 * Method:    setClimateSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setClimateSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray clmate_indexs,
         jintArray availabilities, jintArray data) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;
    //处理config_indexs
    int clmate_indexs_len = env->GetArrayLength(clmate_indexs);
    LOGE("clmate_indexs_len: %d", clmate_indexs);
    std::string climate_indexs[clmate_indexs_len];
    for (int j = 0; j < clmate_indexs_len; j++) {
        jobject climate_object = env->GetObjectArrayElement(clmate_indexs, j);
        //jobject转化为jstring
        jstring climate_jstring = static_cast<jstring>(climate_object);
        //jstring转化为string
        const char *climate_char = (*env).GetStringUTFChars(climate_jstring, 0);
        climate_indexs[j] = climate_char;
        LOGE("climate_char: %s", climate_char, " climate_indexs[j]: %s", climate_indexs[j].c_str());
    }

    //处理availabilities
    int *tmp_availabilities = (*env).GetIntArrayElements(availabilities, JNI_FALSE);
    int availabilities_len = (*env).GetArrayLength(availabilities);
    LOGE("availabilities_len: %d", availabilities_len);
    int vAvailabilities[availabilities_len];
    for (int i = 0; i < availabilities_len; i++) {
        vAvailabilities[i] = tmp_availabilities[i];
        LOGE("vAvailabilities[%d]: %d", i, vAvailabilities[i]);
    }

    //处理data
    int *tmp_data = (*env).GetIntArrayElements(data, JNI_FALSE);
    int data_len = (*env).GetArrayLength(data);
    LOGE("data_len: %d", data_len);
    int vData[data_len];
    for (int i = 0; i < data_len; i++) {
        vData[i] = tmp_data[i];
        LOGE("vData[%d]: %d", i, vData[i]);
    }

    bool res = set_climate_signal(service_id, op_id, climate_indexs, vAvailabilities,vData, clmate_indexs_len);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setClimaSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setClimaSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray climates, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;
    int climate_len = env->GetArrayLength(climates);
    std::string climate_indexs[climate_len];
    for (int j = 0; j < climate_len; j++) {
        jobject climate_object = env->GetObjectArrayElement(climates, j);
        //jobject转化为jstring
        jstring climate_jstring = static_cast<jstring>(climate_object);
        //jstring转化为string
        const char *climate_char = (*env).GetStringUTFChars(climate_jstring, 0);
        climate_indexs[j] = climate_char;
    }
    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
    }
    bool res = set_clima_signal(service_id, op_id, climate_indexs, vValues, climate_len);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setCEMSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setCEMSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray cems, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;
    //处理cems
    int cem_len = env->GetArrayLength(cems);
    LOGE("cem_len: %d", cem_len);
    std::string cem_indexs[cem_len];
    for (int j = 0; j < cem_len; j++) {
        jobject cem_object = env->GetObjectArrayElement(cems, j);
        //jobject转化为jstring
        jstring cem_jstring = static_cast<jstring>(cem_object);
        //jstring转化为string
        const char *cem_char = (*env).GetStringUTFChars(cem_jstring, 0);
        LOGE("cem_char: %s", cem_char);
        cem_indexs[j] = cem_char;
        LOGE("cem_indexs[j]: %s", cem_indexs[j].c_str());
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d", i, vValues[i]);
    }

    bool res = set_cem_signal(service_id, op_id, cem_indexs, vValues, cem_len);
    return res;
}/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setDMSMSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setDMSMSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray dmsm, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;

    int dmsm_len = env->GetArrayLength(dmsm);
    LOGE("dmsm_len: %d", dmsm_len);
    std::string dmsm_indexs[dmsm_len];
    for (int j = 0; j < dmsm_len; j++) {
        jobject dmsm_object = env->GetObjectArrayElement(dmsm, j);
        //jobject转化为jstring
        jstring dmsm_jstring = static_cast<jstring>(dmsm_object);
        //jstring转化为string
        const char *dmsm_char = (*env).GetStringUTFChars(dmsm_jstring, 0);
        LOGE("dmsm_char: %s", dmsm_char);
        dmsm_indexs[j] = dmsm_char;
        LOGE("dmsm_indexs[j]: %s", dmsm_indexs[j].c_str());
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d", i, vValues[i]);
    }

    bool res = set_dmsm_signal(service_id, op_id, dmsm_indexs, vValues, dmsm_len);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setBBMSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setBBMSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray bbms, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;
    //处理bbms
    int bbm_len = env->GetArrayLength(bbms);
    LOGE("bbm_len: %d", bbm_len);
    std::string bbm_indexs[bbm_len];
    for (int j = 0; j < bbm_len; j++) {
        jobject bbm_object = env->GetObjectArrayElement(bbms, j);
        //jobject转化为jstring
        jstring bbm_jstring = static_cast<jstring>(bbm_object);
        //jstring转化为string
        const char *bbm_char = (*env).GetStringUTFChars(bbm_jstring, 0);
        LOGE("bbm_char: %s", bbm_char);
        bbm_indexs[j] = bbm_char;
        LOGE("bbm_indexs[j]: %s", bbm_indexs[j].c_str());
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d", i, vValues[i]);
    }

    bool res = set_bbm_signal(service_id, op_id, bbm_indexs, vValues, bbm_len);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setASDMSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setASDMSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray arrs, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;
    //处理aars
    int len = env->GetArrayLength(arrs);
    LOGE("len: %d", len);
    std::string indexs[len];
    for (int j = 0; j < len; j++) {
        jobject object = env->GetObjectArrayElement(arrs, j);
        //jobject转化为jstring
        jstring ob2jstring = static_cast<jstring>(object);
        //jstring转化为string
        const char *obchar = (*env).GetStringUTFChars(ob2jstring, 0);
        LOGE("char: %s", obchar);
        indexs[j] = obchar;
        LOGE("indexs[j]: %s", indexs[j].c_str());
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d", i, vValues[i]);
    }

    bool res = set_asdm_signal(service_id, op_id, indexs, vValues, len);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setPDCMSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setPDCMSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray arrs, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;
    //处理aars
    int len = env->GetArrayLength(arrs);
    LOGE("len: %d", len);
    std::string indexs[len];
    for (int j = 0; j < len; j++) {
        jobject object = env->GetObjectArrayElement(arrs, j);
        //jobject转化为jstring
        jstring ob2jstring = static_cast<jstring>(object);
        //jstring转化为string
        const char *obchar = (*env).GetStringUTFChars(ob2jstring, 0);
        LOGE("char: %s", obchar);
        indexs[j] = obchar;
        LOGE("indexs[j]: %s", indexs[j].c_str());
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d", i, vValues[i]);
    }

    bool res = set_pdcm_signal(service_id, op_id, indexs, vValues, len);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setCDMSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setCDMSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray cdms, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;
    //处理cdms
    int cdm_len = env->GetArrayLength(cdms);
    LOGE("cdm_len: %d", cdm_len);
    std::string cdm_indexs[cdm_len];
    for (int j = 0; j < cdm_len; j++) {
        jobject cdm_object = env->GetObjectArrayElement(cdms, j);
        //jobject转化为jstring
        jstring cdm_jstring = static_cast<jstring>(cdm_object);
        //jstring转化为string
        const char *cdm_char = (*env).GetStringUTFChars(cdm_jstring, 0);
        LOGE("cdm_char: %s", cdm_char);
        cdm_indexs[j] = cdm_char;
        LOGE("cdm_indexs[j]: %s", cdm_indexs[j].c_str());
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d", i, vValues[i]);
    }

    bool res = set_cdm_signal(service_id, op_id, cdm_indexs, vValues, cdm_len);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setHUDSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setHUDSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray arrs, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;

    int hud_len = env->GetArrayLength(arrs);
    LOGE("hud_len: %d", hud_len);
    std::string hud_indexs[hud_len];
    for (int j = 0; j < hud_len; j++) {
        jobject cdm_object = env->GetObjectArrayElement(arrs, j);
        //jobject转化为jstring
        jstring cdm_jstring = static_cast<jstring>(cdm_object);
        //jstring转化为string
        const char *cdm_char = (*env).GetStringUTFChars(cdm_jstring, 0);
        LOGE("cdm_char: %s", cdm_char);
        hud_indexs[j] = cdm_char;
        LOGE("hud_indexs[j]: %s", hud_indexs[j].c_str());
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d", i, vValues[i]);
    }

    bool res = set_hud_signal(service_id, op_id, hud_indexs, vValues, hud_len);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setHUDSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setDimHUDSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray arrs, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;

    int hud_len = env->GetArrayLength(arrs);
    LOGE("hud_len: %d", hud_len);
    std::string hud_indexs[hud_len];
    for (int j = 0; j < hud_len; j++) {
        jobject cdm_object = env->GetObjectArrayElement(arrs, j);
        //jobject转化为jstring
        jstring cdm_jstring = static_cast<jstring>(cdm_object);
        //jstring转化为string
        const char *cdm_char = (*env).GetStringUTFChars(cdm_jstring, 0);
        LOGE("cdm_char: %s", cdm_char);
        hud_indexs[j] = cdm_char;
        LOGE("hud_indexs[j]: %s", hud_indexs[j].c_str());
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d", i, vValues[i]);
    }

    bool res = set_dim_hud_signal(service_id, op_id, hud_indexs, vValues, hud_len);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setCCSMSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setCCSMSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray ccsm, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;
    //处理ccsm
    int ccsm_len = env->GetArrayLength(ccsm);
    LOGE("ccsm_len: %d", ccsm_len);
    std::string ccsm_indexs[ccsm_len];
    for (int j = 0; j < ccsm_len; j++) {
        jobject ccsm_object = env->GetObjectArrayElement(ccsm, j);
        //jobject转化为jstring
        jstring ccsm_jstring = static_cast<jstring>(ccsm_object);
        //jstring转化为string
        const char *ccsm_char = (*env).GetStringUTFChars(ccsm_jstring, 0);
        LOGE("cem_char: %s", ccsm_char);
        ccsm_indexs[j] = ccsm_char;
        LOGE("cem_indexs[j]: %s", ccsm_indexs[j].c_str());
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d", i, vValues[i]);
    }

    bool res = set_ccsm_signal(service_id, op_id, ccsm_indexs, vValues, ccsm_len);
    return res;
}

/*
 * Class:     com_ecarx_vhaltests_IpcpClient
 * Method:    setSWSMSignal
 * Signature: (II[Ljava/lang/String;[I)Z
 */
JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setSWSMSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray swsm, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;
    //处理swsm
    int swsm_len = env->GetArrayLength(swsm);
    LOGE("swsm_len: %d", swsm_len);
    std::string swsm_indexs[swsm_len];
    for (int j = 0; j < swsm_len; j++) {
        jobject swsm_object = env->GetObjectArrayElement(swsm, j);
        //jobject转化为jstring
        jstring swsm_jstring = static_cast<jstring>(swsm_object);
        //jstring转化为string
        const char *swsm_char = (*env).GetStringUTFChars(swsm_jstring, 0);
        LOGE("swsm_char: %s", swsm_char);
        swsm_indexs[j] = swsm_char;
        LOGE("swsm_indexs[j]: %s", swsm_indexs[j].c_str());
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d", i, vValues[i]);
    }

    bool res = set_swsm_signal(service_id, op_id, swsm_indexs, vValues, swsm_len);
    return res;
}

JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setFPLSignal
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray fpl, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;
    //处理fpl
    int fpl_len = env->GetArrayLength(fpl);
    LOGE("fpl: %d", fpl_len);
    std::string fpl_indexs[fpl_len];
    for (int j = 0; j < fpl_len; j++) {
        jobject fpl_object = env->GetObjectArrayElement(fpl, j);
        //jobject转化为jstring
        jstring fpl_jstring = static_cast<jstring>(fpl_object);
        //jstring转化为string
        const char *fpl_char = (*env).GetStringUTFChars(fpl_jstring, 0);
        LOGE("fpl_char: %s", fpl_char);
        fpl_indexs[j] = fpl_char;
        LOGE("swsm_indexs[j]: %s", fpl_indexs[j].c_str());
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d", i, vValues[i]);
    }

    bool res = set_fpl_signal(service_id, op_id, fpl_indexs, vValues, fpl_len);
    return res;
}

JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setSwcOdoOfTripInfo
        (JNIEnv *env, jobject, jint ser_id, jint oper_id, jobjectArray fpl, jintArray values) {
    int service_id = (int) ser_id;
    int op_id = (int) oper_id;
    //处理fpl
    int fpl_len = env->GetArrayLength(fpl);
    LOGE("SwcOdoOfTripInfo: %d", fpl_len);
    std::string fpl_indexs[fpl_len];
    for (int j = 0; j < fpl_len; j++) {
    jobject fpl_object = env->GetObjectArrayElement(fpl, j);
    //jobject转化为jstring
    jstring fpl_jstring = static_cast<jstring>(fpl_object);
    //jstring转化为string
    const char *fpl_char = (*env).GetStringUTFChars(fpl_jstring, 0);
    LOGE("SwcOdoOfTripInfo_char: %s", fpl_char);
    fpl_indexs[j] = fpl_char;
    LOGE("SwcOdoOfTripInfo_indexs[j]: %s", fpl_indexs[j].c_str());
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
    vValues[i] = tmp_values[i];
    LOGE("cValues[%d]: %d", i, vValues[i]);
    }

    bool res = set_sooti_signal(service_id, op_id, fpl_indexs, vValues, fpl_len);
    return res;
}

JNIEXPORT jboolean JNICALL Java_com_ecarx_vhaltests_IpcpClient_setPowerCtrlSignal
        (JNIEnv *env, jobject, jint svc_id, jint oper_id,  jobjectArray pwrctl, jintArray values){

    int service_id = (int) svc_id;
    int op_id = (int) oper_id;
    //处理powrct;
    int pwrctl_len = env->GetArrayLength(pwrctl);
    LOGE("pwrctllen: %d", pwrctl);
    std::string pwrctl_indexs[pwrctl_len];
    for (int j = 0; j < pwrctl_len; j++) {
        jobject pwrctl_object = env->GetObjectArrayElement(pwrctl, j);
        //jobject转化为jstring
        jstring pwrctl_jstring = static_cast<jstring>(pwrctl_object);
        //jstring转化为string
        const char *pwrctl_char = (*env).GetStringUTFChars(pwrctl_jstring, 0);
        LOGE("pwrctl_char: %s", pwrctl_char);
        pwrctl_indexs[j] = pwrctl_char;
        LOGE("pwrctl_indexs[j]: %s", pwrctl_indexs[j].c_str());
    }

    //处理values
    int *tmp_values = (*env).GetIntArrayElements(values, JNI_FALSE);
    int v_len = (*env).GetArrayLength(values);
    LOGE("v_len: %d", v_len);
    int vValues[v_len];
    for (int i = 0; i < v_len; i++) {
        vValues[i] = tmp_values[i];
        LOGE("cValues[%d]: %d", i, vValues[i]);
    }
    bool ret = set_powerctl_signal(service_id, op_id, pwrctl_indexs, vValues, pwrctl_len);
    return ret;
}

#ifdef __cplusplus
}
#endif